package client

func (c *Client) onEvent(m *Pack) {
	id := m.Id
	listener, ok := c.listeners[id]
	if ok {
		listener.fn(m.Msg)
	} else {
		c.delegate.onWarn("event listener with id: " + id + " not found!")
	}
}

func (c *Client) subscribe(pattern *json.Json, fn func(*json.Json)) {
	l := new(listener)
	l.fn = fn
	m := NewPack("subscribe", pattern)
	id := m.Id
	c.listeners[id] = l
	c.addRequest(id, m, c.defaultCb, false)
}

func (c *Client) unsubscribe(pattern *json.Json, fn func(*json.Json)) {

}
